export function delay(cal: Function, _delay = 200) {
  let time: any
  return function (...params: any[]) {
    time && clearTimeout(time)
    time = setTimeout(() => cal(...params), _delay)
  }
}
// 封装press事件，

export function customPress(
  cal: (type: 'doubleClick' | 'click', ...params: any) => any,
  _delay = 400,
) {
  let time: any
  return function (...params: any[]) {
    params[0] &&
      params[0].persist instanceof Function &&
      params[0] &&
      params[0].persist()
    if (time) {
      clearTimeout(time)
      time = null
      cal('doubleClick', ...params)
    } else {
      time = setTimeout(() => {
        cal('click', ...params)
        time = null
      }, _delay)
    }
  }
}
